#!/bin/bash

rlogin=$1
rhost=$2
rdir=$3
rfile=$4

print_usage()
{
   echo "Usage: $0 <login> <remote host> <remote dir> <remote file>"
   echo "Download the given remote file of the given remote directory "
   echo "on the given remote host by using FTP protocol."
}

if [ "x$rfile" == "x" ]; then
   echo "[ERROR] All arguments not available."
   print_usage
   exit 1
fi

sftp $rlogin@$rhost <<EOSFTP
cd "$rdir"
get "$rfile"
quit
EOSFTP


